package com.bolehui.web;

import com.bolehui.base.result.Result;
import com.bolehui.domain.dto.experience.EducationExperienceDTO;
import com.bolehui.domain.dto.experience.JobExpectationDTO;
import com.bolehui.domain.dto.experience.ProjectExperienceDTO;
import com.bolehui.domain.dto.experience.WorkExperienceDTO;
import com.bolehui.domain.po.experience.EducationExperiencePO;
import com.bolehui.domain.po.experience.JobExpectationPO;
import com.bolehui.domain.po.experience.ProjectExperiencePO;
import com.bolehui.domain.po.experience.WorkExperiencePO;
import com.bolehui.service.experience.EducationExperienceService;
import com.bolehui.service.experience.JobExpectationService;
import com.bolehui.service.experience.ProjectExperienceService;
import com.bolehui.service.experience.WorkExperienceService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chendongjie     email:chendongjie@gz.iscas.ac.cn
 * @version 1.0
 * @ClassName ExperienceController
 * @Description
 * @createTime 2024/12/16 19:57
 * Copyright (C) 2021-2022 CASEEDER, All Rights Reserved.
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 */
@RestController
@RequestMapping("/experience")
public class ExperienceController {

    @Autowired
    private EducationExperienceService educationExperienceService;
    @Autowired
    private WorkExperienceService workExperienceService;
    @Autowired
    private ProjectExperienceService projectExperienceService;
    @Autowired
    private JobExpectationService jobExpectationService;

    @RequestMapping("/saveEducationExperience")
    public Result save(EducationExperienceDTO dto){
        EducationExperiencePO educationExperiencePO = new EducationExperiencePO();
        BeanUtils.copyProperties(dto, educationExperiencePO);
        return Result.success(educationExperienceService.save(educationExperiencePO));
    }

    @RequestMapping("/updateEducationExperience")
    public Result update(EducationExperienceDTO dto){
        EducationExperiencePO educationExperiencePO = new EducationExperiencePO();
        BeanUtils.copyProperties(dto, educationExperiencePO);
        return Result.success(educationExperienceService.updateById(educationExperiencePO));
    }

    @RequestMapping("/saveWorkExperience")
    public Result save(WorkExperienceDTO dto){
        WorkExperiencePO workExperiencePO = new WorkExperiencePO();
        BeanUtils.copyProperties(dto, workExperiencePO);
        return Result.success(workExperienceService.save(workExperiencePO));
    }

    @RequestMapping("/updateWorkExperience")
    public Result update(WorkExperienceDTO dto){
        WorkExperiencePO workExperiencePO = new WorkExperiencePO();
        BeanUtils.copyProperties(dto, workExperiencePO);
        return Result.success(workExperienceService.updateById(workExperiencePO));
    }

    @RequestMapping("/saveProjectExperience")
    public Result save(ProjectExperienceDTO dto){
        ProjectExperiencePO projectExperiencePO = new ProjectExperiencePO();
        BeanUtils.copyProperties(dto, projectExperiencePO);
        return Result.success(projectExperienceService.save(projectExperiencePO));
    }

    @RequestMapping("/updateProjectExperience")
    public Result update(ProjectExperienceDTO dto){
        ProjectExperiencePO projectExperiencePO = new ProjectExperiencePO();
        BeanUtils.copyProperties(dto, projectExperiencePO);
        return Result.success(projectExperienceService.updateById(projectExperiencePO));
    }

    @RequestMapping("/saveJobExpectation")
    public Result save(JobExpectationDTO dto){
        JobExpectationPO jobExpectationPO = new JobExpectationPO();
        BeanUtils.copyProperties(dto, jobExpectationPO);
        return Result.success(jobExpectationService.save(jobExpectationPO));
    }

    @RequestMapping("/updateJobExpectation")
    public Result update(JobExpectationDTO dto){
        JobExpectationPO jobExpectationPO = new JobExpectationPO();
        BeanUtils.copyProperties(dto, jobExpectationPO);
        return Result.success(jobExpectationService.updateById(jobExpectationPO));
    }

}
